package br.inf.mensageiro.util;

import java.io.IOException;

import br.inf.mensageiro.context.ApplicationContext;
import br.inf.mensageiro.multicast.ServerMulticast;
import br.inf.mensageiro.pojo.Status;


public class EnviaThread  extends Thread{  
	private Status status;
	private String ipRemote;
	
	public EnviaThread(String ipRemote, Status status){
		this.status = status;
		this.ipRemote = ipRemote;
	}
	
	public void run(){  
		try {
			if(!ApplicationContext.getInstance().getNodeMap().containsKey(ipRemote)){
				ServerMulticast.send(status);			
				Thread.sleep(1000);
			}
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}  
	}  
}
